package com.fliad.ai.controller;

import cn.hutool.core.util.IdUtil;
import com.fliad.ai.entity.AiLlm;
import com.fliad.ai.service.AiLlmService;
import org.noear.solon.annotation.*;
import org.noear.solon.core.handle.Result;

import java.sql.SQLException;
import java.util.List;

/**
 * 大模型控制器
 */
public class AiLlmController {

    @Inject
    AiLlmService aiLlmService;

    // 创建大模型
    @Post
    @Mapping("")
    public Result<Boolean> create(@Body AiLlm llm) throws SQLException {
        llm.setId(IdUtil.getSnowflakeNextId());
        return Result.succeed(aiLlmService.create(llm));
    }

    // 查询单个大模型
    @Get
    @Mapping("/{id}")
    public Result<AiLlm> get(@Path("id") Long id) throws SQLException {
        return Result.succeed(aiLlmService.get(id));
    }

    // 查询大模型列表
    @Get
    @Mapping("")
    public Result<List<AiLlm>> list(String title, String dialect, Boolean supportChat, Boolean supportEmbed) throws SQLException {
        return Result.succeed(aiLlmService.list(title, dialect, supportChat, supportEmbed));
    }

    // 更新大模型
    @Put
    @Mapping("/{id}")
    public Result<Boolean> update(@Path("id") Long id, @Body AiLlm llm) throws SQLException {
        return Result.succeed(aiLlmService.update(id, llm));
    }

    // 删除大模型
    @Delete
    @Mapping("/{id}")
    public Result<Boolean> delete(@Path("id") Long id) throws SQLException {
        return Result.succeed(aiLlmService.delete(id));
    }
}
